#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a[9] = { 1,2,3,4,5,6,7,8,9 };
	int resultcount = 0;
	do
	{
		if ((a[0] * 100 + a[1] * 10 + a[2]) + (a[3] * 100 + a[4] * 10 + a[5]) == (a[6] * 100 + a[7] * 10 + a[8]))
		{
			resultcount++;
		}
	} while (next_permutation(a, a + 9));
	cout << resultcount;
	return 0;
 }